home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _50DBB4C2F46A40A388B80245D036768C < prev    next >
Encoding:
Text File  |  2004-01-06  |  2.4 KB  |  94 lines

  1. Script:LoadScript("scripts/default/entities/pickups/basepickup.lua");
  2.  
  3. local funcPick=function (self, collider, entering)
  4.  
  5.     --printf("collider health is %d < %d >  tm< %d >", collider.cnt.health, self.Properties.Amount, self.Properties.RespawnTime);
  6.  
  7.     if(collider.cnt.health>=collider.cnt.max_health)then
  8.         if (entering == 1) then
  9.             self:NotifyMessage("@medi_pickup_not_possible", collider,2);
  10.         end
  11.         return nil;
  12.     end    
  13.  
  14.     collider.cnt.health = collider.cnt.health + self.Properties.Amount;
  15.     if(collider.cnt.health>collider.cnt.max_health)then
  16.         collider.cnt.health=collider.cnt.max_health;
  17.     end
  18.     self:NotifyMessage("@YouPickedUp "..self.Properties.Amount.." @UnitsOf @Health",collider)
  19.  
  20.     -- multiplayer statistics
  21.     local colliderSSID = (Server:GetServerSlotByEntityId(collider.id)):GetId();
  22.     
  23.     if (self.shooterSSID and colliderSSID~=self.shooterSSID) then-- if the health packed was launched by a player, and if this player is not the same that launched the heal
  24.         MPStatistics:AddStatisticsData(self,"nHealed",1);
  25.     end
  26.     
  27.     return 1;
  28. end
  29.  
  30. local params={
  31.     func=funcPick,
  32.     model="Objects/pickups/health/medikit.cgf",
  33.     default_amount=50,
  34.     sound="sounds/items/health.wav",
  35.     modelchoosable=nil,
  36.     soundchoosable=nil,
  37.     floating_icon="Objects/Pickups/health/health_icon.cga"
  38. }
  39.  
  40. Health=CreateCustomPickup(params);
  41.  
  42.  
  43. Health._OnInit=Health.Client.OnInit;
  44. function Health.Client:OnInit()
  45.     self:_OnInit();
  46.     self:SetViewDistRatio(255);
  47. end
  48.  
  49.  
  50. Health.PhysParam = {
  51.     mass = 10,
  52.     size = 0.15,
  53.     heading = {x=0,y=0,z=-1},
  54.     initial_velocity = 6,
  55.     k_air_resistance = 0,
  56.     acc_thrust = 0,
  57.     acc_lift = 0,
  58.     --high friction material
  59.     surface_idx = Game:GetMaterialIDByName("mat_pickup"),
  60.     gravity = {x=0, y=0, z=-9.8 },
  61.     collider_to_ignore = nil,
  62.     constant_orientation=1
  63. }
  64.  
  65.  
  66.  
  67.  
  68. function Health:Launch( weapon, shooter, pos, angles, dir, target )
  69.     self.PhysParam.heading = dir;
  70.  
  71.     self:SetPhysicParams( PHYSICPARAM_PARTICLE, self.PhysParam );
  72.     self:EnableSave(nil);
  73.     -- fade away after 15 seconds
  74.     self:SetTimer(15000);
  75.  
  76.     pos.x = pos.x + 1.5*dir.x;
  77.     pos.y = pos.y + 1.5*dir.y;
  78.     pos.z = pos.z + 1.5*dir.z;
  79.  
  80.     self:SetPos( pos );
  81.     self:SetAngles( angles );
  82.     self:NetPresent(1);
  83.     
  84.     -- the ID of the server slot who initiated the action
  85.     -- used for statistics
  86.     local serverSlot = Server:GetServerSlotByEntityId(shooter.id);
  87.     
  88.     if (serverSlot) then
  89.         self.shooterSSID = serverSlot:GetId();
  90.     end
  91. end
  92.  
  93.  
  94.